package dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import model.Noticia;


public class NoticiaDAO {
	 
	private EntityManager em;
		
		public NoticiaDAO(EntityManager em){
			this.em = em;
		}
		
		public void adicionar(Noticia n){
			em.merge(n);
		}
		public void remove(Noticia n) {
			Noticia n1 = em.merge(n);
			em.remove(n1);		
		}
		public List<Noticia> listar() {
			Query q = em.createQuery("select u from Noticia u");
			return q.getResultList();
		}
}
